<?php
namespace app\data_magic\controller;

use think\Db;
use app\data_magic\logic\Scene;
use cmf\controller\HomeBaseController;
use app\data_magic\logic\Action;
use think\View;

/**
 * 基于Action的前台页面
 */
class ActionController extends WidgetController
{
    //显示指定操作，指定数据id的页面
    public function openDemo()
    {
        $action=new Action();
        if(!$action->init(28)){
            $this->error($action->getError());
        }
        if(!$action->access("11",["admin"])){
            $this->error("没有操作权限");
        }
        $html=$this->dispath($action,["data_id"=>6]);

        $action2=new Action();
        if(!$action2->init(24)){
            $this->error($action->getError());
        }
        if(!$action2->access("11",["admin"])){
            $this->error("没有操作权限");
        }

        $html.=$this->dispath($action2,["filter"=>["customer_id"=>$action->item["id"]]]);
        $this->assign("widget",$html);
        return $this->fetch("demo");
    }
    public function open()
    {
        $action=new Action();
        if(!$action->init(input("action_id"))){
            $this->error($action->getError());
        }
        if(!$action->access("11",["admin"])){
            $this->error("没有操作权限");
        }
        $this->assign("widget",$this->dispath($action,input()));
        return $this->fetch("demo");
    }
}
